package nsfs

import (
	"encoding/hex"
	"fmt"
)

type RightsId struct {
	RightsId string
}

func NewRightsId(rightsId []byte) *RightsId {
	return &RightsId{
		RightsId: hex.EncodeToString(rightsId),
	}
}

type DirectoryEntryType uint8

func (d DirectoryEntryType) String() string {
	switch d {
	case DirectoryEntryTypeDirectory:
		return "Directory"
	case DirectoryEntryTypeFile:
		return "File"
	default:
		return fmt.Sprintf("DirectoryEntryType(%d)", d)
	}
}

const (
	DirectoryEntryTypeDirectory = DirectoryEntryType(iota)
	DirectoryEntryTypeFile      = DirectoryEntryType(iota)
)

type DirectoryEntryEx struct {
	Name             string
	Path             string
	Type             DirectoryEntryType
	Size             int64
	NxFileAttributes NxFileAttribute
}

func NewDirectoryEntryEx(name string, path string, directoryEntryType DirectoryEntryType, size int64) *DirectoryEntryEx {
	return &DirectoryEntryEx{
		Name: name,
		Path: path,
		Type: directoryEntryType,
		Size: size,
	}
}

type NxFileAttribute uint8

func (n NxFileAttribute) String() string {
	switch n {
	case NxFileAttributeNone:
		return "None"
	case NxFileAttributeDirectory:
		return "Directory"
	case NxFileAttributeArchive:
		return "Archive"
	default:
		return fmt.Sprintf("NxFileAttribute(%d)", n)
	}
}

const (
	NxFileAttributeNone      = NxFileAttribute(iota)
	NxFileAttributeDirectory = NxFileAttribute(iota)
	NxFileAttributeArchive   = NxFileAttribute(iota)
)

type DirectoryEntry struct {
	Name        string
	Attributes  NxFileAttribute
	Reserved302 [2]byte
	Type        DirectoryEntryType
	Reserved305 []byte
	Size        int64
}
